package com.tjp.eight;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tjp.eight.comment.AppManager;
import com.tjp.eight.utils.ApplicationUtil;
import com.tjp.eight.utils.StringUtils;

/**
 * Created by Administrator on 2017/3/29.
 */
public class FragWelcome extends Fragment {
    View mContentView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mContentView = super.onCreateView(inflater, container, savedInstanceState);
        if (mContentView == null) {
            mContentView = inflater.inflate(R.layout.frag_welcome, container, false);
            initViews();
        }
        return mContentView;
    }

    void initViews() {
        TextView welcome_version = (TextView) mContentView.findViewById(R.id.welcome_version);
        if (!StringUtils.isNullOrEmpty(ApplicationUtil.getVerName(ApplicationUtil.getApplicationContext()))) {
            welcome_version.setText("v" + ApplicationUtil.getVerName(ApplicationUtil.getApplicationContext()));
        }


        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (getActivity() == null)
                    return;
                AppManager.getAppManager().notFinishActivity(MainActivity.class);
                startActivity(new Intent(getActivity(), MainActivity.class));

            }
        }, 2000);
    }
}
